package com.lyy.controller;


import com.github.pagehelper.PageInfo;
import com.lyy.entity.Video;
import com.lyy.result.Result;
import com.lyy.service.VideoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;

/**
 * @author Liangyaoyun
 */
//@RestController=@Controller+@ResponseBody(返回json数据)
@RestController
@RequestMapping("/api/v1/video")
@Tag(name = "Video接口")
public class VideoController {
    @Autowired
    public VideoService videoService;

    @Operation(summary = "查看视频详情")
    @GetMapping("/selectByVideoId/{videoId}")
    public Result selectByVideoId(@PathVariable Integer videoId) {
        Video video = videoService.selectByVideoId(videoId);
        return new Result(video);
    }

    @Operation(summary = "查看视频详情")
    @GetMapping("/searchByVideoTitle")
    public Result searchByVideoTitle(@RequestParam Integer pageNum,@RequestParam Integer pageSize,
                                     @RequestParam String videoTitle) {
        PageInfo<Video>videoPageInfo=videoService.searchByVideoTitle(videoTitle,pageNum,pageSize);
        return new Result(videoPageInfo);
    }
}
